﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Vim25Api;

namespace Wicresoft.EKA.VCenter.Tests
{
    [TestClass]
    public class EventsTest
    {
        [TestMethod]
        public void TestMethod1()
        {
            OptionSpec url = new OptionSpec("url", "https://192.168.85.208/sdk");
            //OptionSpec url = new OptionSpec("url", "https://192.168.85.191/sdk");
            //OptionSpec url = new OptionSpec("url", "https://192.168.1.114/sdk");
            OptionSpec userName = new OptionSpec("userName", "Administrator");
            //OptionSpec userName = new OptionSpec("userName", "root");
            OptionSpec password = new OptionSpec("password", "Pass01!");

            ExtendedAppUtil app = ExtendedAppUtil.InitializeV25("Test", new OptionSpec[] { url, userName, password });
            app.Connect();

            ManagedObjectReference vms = app.ServiceUtilV25.GetMoRef(null, "VirtualMachine", "vCenter_Server_2");

            EventFilterSpec efs = new EventFilterSpec();
            //EventFilterSpecByEntity efsEntry = new EventFilterSpecByEntity();
            //efsEntry.entity =
            efs.entity = new EventFilterSpecByEntity() { entity = vms };

            ManagedObjectReference eventManager = app.ServiceConnectionV25.ServiceContent.eventManager;

            Event[] events=app.ServiceConnectionV25.Service.QueryEvents(eventManager,efs);

            ManagedObjectReference mo = app.ServiceUtilV25.GetMoRef(null, "Datstore", "Data");
            Console.WriteLine(mo.ToString());
        }
    }
}
